# coding=utf-8
import pandas as pd
import torch
import torch.nn as nn
from torch.utils.data import DataLoader, Dataset

data = pd.read_csv('../data/data.csv')


# print(data)

class MyDataset(Dataset):
    def __init__(self):
        super(MyDataset, self).__init__()

    def __len__(self):
        return len(data)

    def __getitem__(self, i):
        x, y = data.iloc[i]
        x = [int(i) for i in x.split(',')]
        x = torch.LongTensor(x)

        y = int(y)

        return x, y


dataset = MyDataset()
dataloader = DataLoader(dataset=dataset, batch_size=10, shuffle=True, num_workers=6, drop_last=True)

if __name__ == '__main__':
    for i, (x, y) in enumerate(dataloader):
        print(i, (x, y))
        break
